package home.projects.withinaoptest.framework;

import java.util.Collection;
import java.util.Map;

public class CommonChain implements Chain {

   private Collection<Chain> chains;
   
   public CommonChain() {     
   }
   
   public CommonChain(Collection<Chain> chains) {
      this.chains = chains;
   }
   
   private void preProcess(Map<String, Object> map) {
      System.out.println("Preprocessing in CommonChain");
   }
   
   /* (non-Javadoc)
    * @see home.projects.withinaoptest.framework.Chain#execute(java.util.Map)
    */
   public boolean execute(Map<String, Object> map) {
      preProcess(map);
      for(Chain chain : chains) {
         chain.execute(map);
      }
      postProcess(map);
      return false;
   }

   private void postProcess(Map<String, Object> map) {
      System.out.println("Post-Processing in CommonChain");
   }
   
}
